<!DOCTYPE html><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta charset="utf-8">
<title>phpDocumentor » \ActiveRecord\DateTime</title>
<meta name="author" content="Mike van Riel">
<meta name="description" content="">
<link href="../css/template.css" rel="stylesheet" media="all">
<script src="../js/jquery-1.7.1.min.js" type="text/javascript"></script><script src="../js/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script><script src="../js/jquery.mousewheel.min.js" type="text/javascript"></script><script src="../js/bootstrap.js" type="text/javascript"></script><script src="../js/template.js" type="text/javascript"></script><script src="../js/prettify/prettify.min.js" type="text/javascript"></script><link rel="shortcut icon" href="../img/favicon.ico">
<link rel="apple-touch-icon" href="../img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="../img/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="../img/apple-touch-icon-114x114.png">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner"><div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></a><a class="brand" href="../index.html">phpDocumentor</a><div class="nav-collapse"><ul class="nav">
<li class="dropdown">
<a href="#api" class="dropdown-toggle" data-toggle="dropdown">
                                    API Documentation <b class="caret"></b></a><ul class="dropdown-menu">
<li><a>Packages</a></li>
<li><a href="../packages/ActiveRecord.html"><i class="icon-folder-open"></i> ActiveRecord</a></li>
<li><a href="../packages/Default.html"><i class="icon-folder-open"></i> Default</a></li>
</ul>
</li>
<li class="dropdown" id="charts-menu">
<a href="#charts" class="dropdown-toggle" data-toggle="dropdown">
                                    Charts <b class="caret"></b></a><ul class="dropdown-menu"><li><a href="../graph_class.html"><i class="icon-list-alt"></i> Class hierarchy diagram</a></li></ul>
</li>
<li class="dropdown" id="reports-menu">
<a href="#reports" class="dropdown-toggle" data-toggle="dropdown">
                                    Reports <b class="caret"></b></a><ul class="dropdown-menu">
<li><a href="../errors.html"><i class="icon-remove-sign"></i> Errors 
                <span class="label label-info">310</span></a></li>
<li><a href="../markers.html"><i class="icon-map-marker"></i> Markers 
                <ul><li>todo 
                <span class="label label-info">5</span>
</li></ul></a></li>
<li><a href="../deprecated.html"><i class="icon-stop"></i> Deprecated elements 
                <span class="label label-info">3</span></a></li>
</ul>
</li>
</ul></div>
</div></div>
<div class="go_to_top"><a href="#___" style="color: inherit">Back to top  <i class="icon-upload icon-white"></i></a></div>
</div>
<div id="___" class="container">
<noscript><div class="alert alert-warning">
                            Javascript is disabled; several features are only available
                            if Javascript is enabled.
                        </div></noscript>
<div class="row">
<div class="span4">
<span class="btn-group visibility" data-toggle="buttons-checkbox"><button class="btn public active" title="Show public elements">Public</button><button class="btn protected" title="Show protected elements">Protected</button><button class="btn private" title="Show private elements">Private</button><button class="btn inherited active" title="Show inherited elements">Inherited</button></span><div class="btn-group view pull-right" data-toggle="buttons-radio">
<button class="btn details" title="Show descriptions and method names"><i class="icon-list"></i></button><button class="btn simple" title="Show only method names"><i class="icon-align-justify"></i></button>
</div>
<ul class="side-nav nav nav-list">
<li class="nav-header">
<i class="icon-custom icon-method"></i> Methods
                    <ul>
<li class="method public "><a href="#method___toString" title="__toString :: "><span class="description">__toString()
        </span><pre>__toString()</pre></a></li>
<li class="method public "><a href="#method_attribute_of" title="attribute_of :: "><span class="description">attribute_of()
        </span><pre>attribute_of()</pre></a></li>
<li class="method public "><a href="#method_format" title="format :: Formats the DateTime to the specified format."><span class="description">Formats the DateTime to the specified format.</span><pre>format()</pre></a></li>
<li class="method public "><a href="#method_get_format" title="get_format :: Returns the format string."><span class="description">Returns the format string.</span><pre>get_format()</pre></a></li>
<li class="method public "><a href="#method_setDate" title="setDate :: "><span class="description">setDate()
        </span><pre>setDate()</pre></a></li>
<li class="method public "><a href="#method_setISODate" title="setISODate :: "><span class="description">setISODate()
        </span><pre>setISODate()</pre></a></li>
<li class="method public "><a href="#method_setTime" title="setTime :: "><span class="description">setTime()
        </span><pre>setTime()</pre></a></li>
<li class="method public "><a href="#method_setTimestamp" title="setTimestamp :: "><span class="description">setTimestamp()
        </span><pre>setTimestamp()</pre></a></li>
</ul>
</li>
<li class="nav-header private">» Private
                    <ul><li class="method private "><a href="#method_flag_dirty" title="flag_dirty :: "><span class="description">flag_dirty()
        </span><pre>flag_dirty()</pre></a></li></ul>
</li>
<li class="nav-header">
<i class="icon-custom icon-property"></i> Properties
                    <ul>
<li class="property public "><a href="#property_DEFAULT_FORMAT" title="$DEFAULT_FORMAT :: Default format used for format() and __toString()"><span class="description"></span><pre>$DEFAULT_FORMAT</pre></a></li>
<li class="property public "><a href="#property_FORMATS" title="$FORMATS :: Pre-defined format strings."><span class="description"></span><pre>$FORMATS</pre></a></li>
</ul>
</li>
<li class="nav-header private">» Private
                    <ul>
<li class="property private "><a href="#property_attribute_name" title="$attribute_name :: "><span class="description"></span><pre>$attribute_name</pre></a></li>
<li class="property private "><a href="#property_model" title="$model :: "><span class="description"></span><pre>$model</pre></a></li>
</ul>
</li>
</ul>
</div>
<div class="span8">
<a id="\ActiveRecord\DateTime"></a><ul class="breadcrumb">
<li>
<a href="../index.html"><i class="icon-custom icon-class"></i></a><span class="divider">\</span>
</li>
<li><a href="../namespaces/ActiveRecord.html">ActiveRecord</a></li>
<li class="active">
<span class="divider">\</span><a href="../classes/ActiveRecord.DateTime.html">DateTime</a>
</li>
</ul>
<div class="element class">
<p class="short_description">An extension of PHP's DateTime class to provide dirty flagging and easier formatting options.</p>
<div class="details">
<div class="long_description"><p>All date and datetime fields from your database will be created as instances of this class.</p>

<p>Example of formatting and changing the default format:</p>

<pre><code>$now = new ActiveRecord\DateTime('2010-01-02 03:04:05');
ActiveRecord\DateTime::$DEFAULT_FORMAT = 'short';

echo $now->format();         # 02 Jan 03:04
echo $now->format('atom');   # 2010-01-02T03:04:05-05:00
echo $now->format('Y-m-d');  # 2010-01-02

# __toString() uses the default formatter
echo (string)$now;           # 02 Jan 03:04
</code></pre>

<p>You can also add your own pre-defined friendly formatters:</p>

<pre><code>ActiveRecord\DateTime::$FORMATS['awesome_format'] = 'H:i:s m/d/Y';
echo $now->format('awesome_format')  # 03:04:05 01/02/2010
</code></pre></div>
<table class="table table-bordered">
<tr>
<th>package</th>
<td><a href="../packages/ActiveRecord.html">ActiveRecord</a></td>
</tr>
<tr>
<th>see</th>
<td><a href="">\ActiveRecord\http://php.net/manual/en/class.datetime.php</a></td>
</tr>
</table>
<h3>
<i class="icon-custom icon-method"></i> Methods</h3>
<a id="method___toString"></a><div class="element clickable method public method___toString" data-toggle="collapse" data-target=".method___toString .collapse">
<h2>__toString()
        </h2>
<pre>__toString() </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
<a id="method_attribute_of"></a><div class="element clickable method public method_attribute_of" data-toggle="collapse" data-target=".method_attribute_of .collapse">
<h2>attribute_of()
        </h2>
<pre>attribute_of($model, $attribute_name) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Parameters</h3>
<div class="subelement argument"><h4>$model</h4></div>
<div class="subelement argument"><h4>$attribute_name</h4></div>
</div></div>
</div>
<a id="method_format"></a><div class="element clickable method public method_format" data-toggle="collapse" data-target=".method_format .collapse">
<h2>Formats the DateTime to the specified format.</h2>
<pre>format(string $format) : string</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"><pre><code>$datetime->format();         # uses the format defined in DateTime::$DEFAULT_FORMAT
$datetime->format('short');  # d M H:i
$datetime->format('Y-m-d');  # Y-m-d
</code></pre></div>
<table class="table table-bordered">
<tr>
<th>see</th>
<td><a href="">\ActiveRecord\FORMATS</a></td>
</tr>
<tr>
<th>see</th>
<td><a href="">\ActiveRecord\get_format</a></td>
</tr>
</table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$format</h4>
<code>string</code><p>A format string accepted by get_format()</p>
</div>
<h3>Returns</h3>
<div class="subelement response">
<code>string</code>formatted date and time string</div>
</div></div>
</div>
<a id="method_get_format"></a><div class="element clickable method public method_get_format" data-toggle="collapse" data-target=".method_get_format .collapse">
<h2>Returns the format string.</h2>
<pre>get_format(string $format) : string</pre>
<div class="labels"><span class="label">Static</span></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"><p>If $format is a pre-defined format in $FORMATS it will return that otherwise
it will assume $format is a format string itself.</p></div>
<table class="table table-bordered"><tr>
<th>see</th>
<td><a href="">\ActiveRecord\FORMATS</a></td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$format</h4>
<code>string</code><p>A pre-defined string format or a raw format string</p>
</div>
<h3>Returns</h3>
<div class="subelement response">
<code>string</code>a format string</div>
</div></div>
</div>
<a id="method_setDate"></a><div class="element clickable method public method_setDate" data-toggle="collapse" data-target=".method_setDate .collapse">
<h2>setDate()
        </h2>
<pre>setDate($year, $month, $day) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Parameters</h3>
<div class="subelement argument"><h4>$year</h4></div>
<div class="subelement argument"><h4>$month</h4></div>
<div class="subelement argument"><h4>$day</h4></div>
</div></div>
</div>
<a id="method_setISODate"></a><div class="element clickable method public method_setISODate" data-toggle="collapse" data-target=".method_setISODate .collapse">
<h2>setISODate()
        </h2>
<pre>setISODate($year, $week, $day) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Parameters</h3>
<div class="subelement argument"><h4>$year</h4></div>
<div class="subelement argument"><h4>$week</h4></div>
<div class="subelement argument"><h4>$day</h4></div>
</div></div>
</div>
<a id="method_setTime"></a><div class="element clickable method public method_setTime" data-toggle="collapse" data-target=".method_setTime .collapse">
<h2>setTime()
        </h2>
<pre>setTime($hour, $minute, $second) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Parameters</h3>
<div class="subelement argument"><h4>$hour</h4></div>
<div class="subelement argument"><h4>$minute</h4></div>
<div class="subelement argument"><h4>$second</h4></div>
</div></div>
</div>
<a id="method_setTimestamp"></a><div class="element clickable method public method_setTimestamp" data-toggle="collapse" data-target=".method_setTimestamp .collapse">
<h2>setTimestamp()
        </h2>
<pre>setTimestamp($unixtimestamp) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Parameters</h3>
<div class="subelement argument"><h4>$unixtimestamp</h4></div>
</div></div>
</div>
<a id="method_flag_dirty"></a><div class="element clickable method private method_flag_dirty" data-toggle="collapse" data-target=".method_flag_dirty .collapse">
<h2>flag_dirty()
        </h2>
<pre>flag_dirty() </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
<h3>
<i class="icon-custom icon-property"></i> Properties</h3>
<a id="property_DEFAULT_FORMAT"> </a><div class="element clickable property public property_DEFAULT_FORMAT" data-toggle="collapse" data-target=".property_DEFAULT_FORMAT .collapse">
<h2></h2>
<pre>$DEFAULT_FORMAT </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
<a id="property_FORMATS"> </a><div class="element clickable property public property_FORMATS" data-toggle="collapse" data-target=".property_FORMATS .collapse">
<h2></h2>
<pre>$FORMATS </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
<a id="property_attribute_name"> </a><div class="element clickable property private property_attribute_name" data-toggle="collapse" data-target=".property_attribute_name .collapse">
<h2></h2>
<pre>$attribute_name </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
<a id="property_model"> </a><div class="element clickable property private property_model" data-toggle="collapse" data-target=".property_model .collapse">
<h2></h2>
<pre>$model </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
</div>
</div>
</div>
</div>
<div class="row"><footer class="span12">
            Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
            Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a12</a> and<br>
            generated on 2013-06-08T13:56:18-04:30.<br></footer></div>
</div>
</body>
</html>
